package com.glory.hzlionpda.base;

import android.app.Application;
import android.content.Context;

import com.pda.platform.ui.ui_pdaplatform.base.FreeUI_InitUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_SharePreferencesUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_StaticMembers;


public class App extends Application {
    public static Context app;
    private static App instance;

    public static App getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        app = getApplicationContext();
        String timeOut = FreeApi_SharePreferencesUtils.getSharePre("TIME_OUT_FILE", "TIME_OUT", getApplicationContext());
        if (timeOut.length() > 0) {
            Constant.DEFAULT_TIME_OUT = timeOut;
        } else {
            FreeApi_SharePreferencesUtils.setSharePre("TIME_OUT_FILE", "TIME_OUT", Constant.DEFAULT_TIME_OUT, getApplicationContext());
        }
        FreeUI_InitUtils.init(getApplicationContext(), this, true, Integer.parseInt(Constant.DEFAULT_TIME_OUT) * 1000L, 0);
        FreeUI_InitUtils.setTheme(FreeApi_StaticMembers.THEME_SKY_BLUE);
        String ip = FreeApi_SharePreferencesUtils.getSharePre("URL_FILE", "URL_IP", getApplicationContext());
        if (ip.length() > 0) {
            Constant.REQUEST_URL = ip;
        } else {
            FreeApi_SharePreferencesUtils.setSharePre("URL_FILE", "URL_IP", Constant.REQUEST_URL, getApplicationContext());
        }
        String fileIP = FreeApi_SharePreferencesUtils.getSharePre("URL_FILE", "FILE_IP", getApplicationContext());
        if (fileIP.length() > 0) {
            Constant.FILE_URL = fileIP;
        } else {
            FreeApi_SharePreferencesUtils.setSharePre("URL_FILE", "FILE_IP", Constant.FILE_URL, getApplicationContext());
        }
    }
}
